home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / switcher / toastercommandhost.rexx < prev    next >
OS/2 REXX Batch file  |  1993-12-13  |  2KB  |  63 lines

  1. /* ToasterCommandHost.rexx -- Provide command host access to Switcher() functions */
  2. /* By Arnie Cachelin  © 1992 NewTek Inc. */
  3.  
  4. /*
  5.    This program acts as a Command Host interface for the Video Toaster Switcher
  6.    which has a 'function host' interface.  The function host interface requires
  7.    that all commands be sent as arguments to the Switcher() function,
  8.    which is defined when the command "ADDLIB('ToasterARexx.port',0)" has
  9.    been executed.  The more common 'command host' type of ARexx interface
  10.    sends command strings to the address specified by the ADDRESS command.
  11.    This type of interface is more compatible with direct control by
  12.    programs like AmigaVision, CanDo, and others.  To start the command host
  13.    interface, first run the Toaster, then run this program.  Now all
  14.    commands sent to "TOASTER_COMMAND_HOST" will be translated into the
  15.    appropriate function calls.  The commands are identical to those described
  16.    in the manual. If you send the command HOST_EXIT, this program will quit.
  17. */
  18.  
  19.  
  20. OPTIONS RESULTS
  21.  
  22. port=TOASTER_COMMAND_HOST   /* This port name will receive commands for the switcher */
  23. HOST_EXIT='HOST_EXIT'       /* Send this string to shut down this program */
  24. TOASTERLIB="ToasterARexx.port"    /* Name of the Toaster function host port */
  25. NULL_PKT = '0000 0000'x
  26. LIBNAME = "rexxsupport.library"
  27.  
  28. IF ~SHOW('Libraries',LIBNAME) THEN
  29.   IF ~ADDLIB(LIBNAME , 0 , -30 , 0) THEN x=Bummer("Cant find "LIBNAME)
  30. IF ~SHOW('Libraries',TOASTERLIB) THEN
  31.   IF ~ADDLIB(TOASTERLIB , 0) THEN x=Bummer("Please start your Video Toaster!")
  32.  
  33. CALL OPENPORT PORT
  34. IF ~SHOW('Ports',PORT) THEN x=Bummer("Can't open port: "port)
  35.  
  36. SAY "Toaster Command Host open for business!"
  37. SAY "Send commands to port: "port
  38. SAY "Send "HOST_EXIT" to shut down command host."
  39. DO FOREVER
  40.   packet = NULL_PKT
  41.   DO WHILE packet = NULL_PKT
  42.     CALL WAITPKT(PORT)
  43.     packet = GETPKT(PORT)
  44.   END
  45.   pktstring = GETARG(packet)
  46.      CALL REPLY(packet,0)  /*  We don't presume to judge the packet ==>no return */
  47.   IF UPPER(pktstring) = HOST_EXIT THEN x=Bummer(" Received "HOST_EXIT" request.")
  48.   pktstring=TRANSLATE(STRIP(pktstring),","," ")  /* replace space with comma */
  49.   FunctionCmd="x=Switcher("pktstring")"
  50.   SAY FunctionCmd
  51.   INTERPRET FunctionCmd
  52. END
  53. EXIT
  54.  
  55. Bummer: PROCEDURE
  56.  ARG etxt
  57.  IF RC~="RC" then
  58.      SAY "ERROR: "||RC||etxt
  59.  ELSE
  60.      SAY "Guess What: "etxt
  61.  EXIT
  62.  RETURN 0
  63.